package api

import (
	"fmt"
	"gin-study-demo/entity"
	"gin-study-demo/model"
	"github.com/gin-gonic/gin"
)

type UserController struct {
}

func (con UserController) Index(c *gin.Context) {
	userList := []entity.User{}
	model.DB.Select("id", 1).Find(&userList)
	fmt.Println(userList)
	c.String(200, "api Index")
}

func (con UserController) Add(c *gin.Context) {
	c.String(200, "api Add")
}

func (con UserController) List(c *gin.Context) {
	//var userOne []entity.User
	var user = []entity.User{}
	model.DB.Find(&user)
	c.JSON(200, gin.H{
		"user": user,
	})
}

func (con UserController) Update(c *gin.Context) {
	c.String(200, "api update")
}

func (con UserController) Delete(c *gin.Context) {
	c.String(200, "api Delete")
}
